package com.hyt.it.ogt.kq.service.bm.feign.file;

import com.hyt.common.utils.exception.BusinessException;
import com.hyt.common.utils.exception.RemoteRequestExcepton;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;


/**
 * 文件服务Feign客户端熔断器
 */
@Component
@Slf4j
public class FileClientHystrix implements FileClient {

	@Override
	public String uploadFile(@RequestPart(value = "file") MultipartFile file) {
		log.error("#上传文件失败，进入熔断");
		return "上传文件失败";
	}

	@Override
	public String uploadFile(@RequestBody byte[] bytes, @RequestParam String format) {
		log.error("#上传byte[]文件失败，进入熔断");
		return "上传byte[]文件失败";
	}

	@Override
	public String uploadFile(@RequestParam String content, @RequestParam String fileExtension) {
		log.error("#上传字符文件失败，进入熔断");
		return "上传字符文件失败";
	}

	@Override
	public String uploadFileByUrl(@RequestParam String url, @RequestParam long fileSize,
			@RequestParam String fileExtension) {
		log.error("#上传文件失败，进入熔断");
		return "上传字符文件失败";
	}

	@Override
	public String uploadImageAndCrtThumbImage(@RequestPart(value = "file") MultipartFile file) {
		log.error("#上传图片并生成缩略图失败，进入熔断");
		return "上传图片并生成缩略图失败";
	}

	@Override
	public String getThumbImagePath(@RequestParam String filePath) {
		log.error("#根据图片路径获取缩略图路径失败，进入熔断");
		return "根据图片路径获取缩略图路径失败";
	}

	@Override
	public void deleteFile(@RequestParam String filePath) {
		log.error("#删除文件失败，进入熔断");

	}

	@Override
	public byte[] downFile(@RequestParam String filePath) throws BusinessException {
		log.error("#下载文件失败，进入熔断");
		throw new RemoteRequestExcepton("下载文件失败");
	}

	@Override
	public InputStream downFileByStream(String filePath) {
		log.error("#下载流文件失败，进入熔断");
		throw new RemoteRequestExcepton("下载流文件失败");
	}

}
